package service;

/**
 * @Title: NoticeServiceImpl.java
 * @Description: TODO
 * @author 18130444郑雅玲
 * @date 2020-12-01 03:33:32
 */

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;

import dao.NoticeDao;
import po.Notice;

@Service("noticeService")
@Transactional
public class NoticeServiceImpl implements NoticeService {
	
	@Autowired
	private NoticeDao noticeDao;
	
	@Override
	public List<Notice> findAllNotice(Notice notice) {
		return noticeDao.findAllNotice(notice);
	}
	
	@Override
	public List<Notice> findNotices(int page){
		return noticeDao.findNotices(page);
	}
	
	@Override
	public int deteleNotice(int id) {
		return noticeDao.deleteNotice(id);
	}
	
	@Override
	public boolean addNotice(Notice notice) {
		if(noticeDao.addNotice(notice) != 0) {
			return true;
		}
		return false;
	}
	
	@Override
	public String selectANotice(Model model, int id) {
		model.addAttribute("notice", noticeDao.selectANotice(id));
		return "noticeDetail";
	}
	
	@Override
	public int pageCount() {
		return (noticeDao.pageCount() + 6) / 7;
	}
}
